// src/api/teacher.js
import request from '@/utils/request'; // 假设项目中已有请求封装

/**
 * 获取教师列表
 * @param {Object} params - 查询参数
 * @param {number} params.pageNum - 当前页码
 * @param {number} params.pageSize - 每页显示数量
 * @param {string} params.query - 搜索关键词
 * @param {number} params.orderBy - 排序方式(后端默认0)
 */
export function getTeacherList(params) {
    return request({
        url: `/teacher/findall/${params.pageNum}/${params.pageSize}/${params.orderBy || 0}`,
        method: 'post',
        data: {
            teacherName: params.query || '' // 假设按姓名搜索
        }
    });
}

/**
 * 获取教师详情
 * @param {string} teacherId - 教师ID
 */
export function getTeacherDetail(teacherId) {
    return request({
        url: `/teacher/${teacherId}`,
        method: 'get'
    });
}

/**
 * 添加教师
 * @param {Object} teacher - 教师信息
 */
export function addTeacher(teacher) {
    return request({
        url: '/teacher/insert',
        method: 'post',
        data: teacher
    });
}

/**
 * 修改教师
 * @param {Object} teacher - 教师信息
 */
export function updateTeacher(teacher) {
    return request({
        url: '/teacher/update',
        method: 'put',
        data: teacher
    });
}

/**
 * 删除教师
 * @param {string} teacherId - 教师ID
 */
export function deleteTeacher(teacherId) {
    return request({
        url: `/teacher/delete/${teacherId}`,
        method: 'delete'
    });
}

/**
 * 获取院系列表 (假设另有院系接口)
 */
export function getDepartmentList(pageNum, pageSize, orderBy, params) {
    return request({
        url: `/department/findall/${pageNum}/${pageSize}/${orderBy}`, // 假设院系接口路径
        method: 'post',
        data: params
    });
}